package com.snail.controller;

import cn.hutool.core.util.StrUtil;
import com.snail.model.pojo.media.BizTags;
import com.snail.result.Result;
import com.snail.service.BizTagsService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author Monica
 * @description
 * @date 2025/8/16 14:44
 */
@RestController
@RequestMapping("/tag")
@RequiredArgsConstructor
public class BizTagsController {

    private final BizTagsService bizTagsService;

    @GetMapping("/list")
    private Result<List<BizTags>> getList(){
        List<BizTags> list = bizTagsService.list();
        return Result.success(list);
    }

    @GetMapping("/detail")
    private Result<List<BizTags>> getDetail(String ids){
        String[] idArray = ids.split(",");
        List<Long> idList = Arrays.stream(idArray)
                .filter(StrUtil::isNotEmpty)
                .map(Long::valueOf)
                .toList();
        List<BizTags> list = bizTagsService.lambdaQuery().in(BizTags::getId, idList).list();
        return Result.success(list);
    }
}
